package com.ccl.bigevent.controller;

import com.ccl.bigevent.pojo.Article;
import com.ccl.bigevent.pojo.PageBean;
import com.ccl.bigevent.pojo.Result;
import com.ccl.bigevent.service.ArticleService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Title: ArticleController
 * @Author ccl
 * @Package IntelliJ IDEA
 * @Date 2024/10/7 17:26
 * @description:
 */
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Resource
    private ArticleService articleService;


    @PostMapping("/add")
    public Result add(Article article) {
        articleService.add(article);
        return Result.success();
    }


    @PostMapping("/list")
    public Result<PageBean<Article>> list(
            Integer pageNum,
            Integer pageSize,
            @RequestParam(required = false) Integer categoryId,
            @RequestParam(required = false) String state
    ) {
        return Result.success(articleService.list(pageNum, pageSize, categoryId, state));
    }
}
